package com.lb.pdm.controller;

import com.lb.pdm.common.result.GraceJSONResult;
import com.lb.pdm.entity.bo.KeyPersonnelBO;
import com.lb.pdm.entity.vo.KeyPersonnelVO;
import com.lb.pdm.service.KeyPersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Title: KeyPersonnelController
 * @Author Wood
 * @Package com.lb.pdm.controller
 * @Date 2025/11/3 19:39
 * @description:
 */
@RestController
@RequestMapping("/key-personnel")
public class KeyPersonnelController {
    @Autowired
    private KeyPersonnelService keyPersonnelService;

    @PostMapping("/input")
    public GraceJSONResult input(@RequestBody KeyPersonnelBO keyPersonnelBO, @RequestHeader("token") String token) {
        return keyPersonnelService.inputKeyPersonnel(keyPersonnelBO, token);
    }

    @GetMapping("/query")
    public GraceJSONResult query(@RequestParam(value = "name", required = false) String name,
                                 @RequestParam(value = "idCard", required = false) String idCard,
                                 @RequestParam(value = "category", required = false) String category,
                                 @RequestParam(value = "riskLevel", required = false) Byte riskLevel,
                                 @RequestParam("pageNum") Integer pageNum,
                                 @RequestParam("pageSize") Integer pageSize) {
        List<KeyPersonnelVO> keyPersonnelVOS = keyPersonnelService.query(name, idCard, category, riskLevel, pageNum, pageSize);
        return GraceJSONResult.ok(keyPersonnelVOS);
    }

    @PutMapping("/update")
    public GraceJSONResult update(@RequestParam("id") Long id , @RequestParam("status") Byte status, @RequestHeader("token") String token) {
        return keyPersonnelService.updateKeyPersonnel(id, status, token);
    }


}
